#include "StdAfx.h"
#include "Complexe.h"


Complexe::Complexe(float reel , float imaginaire )
{
	_re = reel ;
	_im = imaginaire;
}


Complexe::Complexe(const Complexe & c)
{
	_re = c._re; 
	_im = c._im;
}


float Complexe::getIm() const{

	return _im;
}

float Complexe::getRe() const{

	return _re;
}

void Complexe::Set(const float re, const float im){
	_re = re;
	_im = im;
}

void Complexe::AfficheSur(std::ostream &flot) const{
	flot << _re << " + i" << _im << std::endl;
}

Complexe & Complexe::operator=( const Complexe & c){
	_re = c._re;
	_im = c._im;

	return *this;
}

Complexe  Complexe::Plus( const Complexe & c) const{
	return Complexe  (_re + c._re , _im + c._re);
}

Complexe Complexe::operator+(const Complexe & c) const{
	return Plus(c);
}


Complexe  Complexe::Fois( const Complexe & c) const{
	return Complexe  (_re * c._re - _im * c._im, _re *c._im + c._re * _im);
}

Complexe Complexe::operator*(const Complexe & c) const{
	return Fois(c);
}

float Complexe::operator[]( const unsigned int i )const {
	switch (i) {
	case 0 : 
		return _re;
		break;
	case 1:
		return _im;
		break;
	default :
		std::cout<< "y a que 2 partie";
		return 0;
	}	
}